package br.com.mucceli.politicapopular.model;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 *
 * @author mucceli
 */
@Entity
@Table(name = "ENQUETE")
@NamedQueries({
    @NamedQuery(name = "Enquete.findAll", query = "SELECT e FROM Enquete e"),
    @NamedQuery(name = "Enquete.findByIdEnquete", query = "SELECT e FROM Enquete e WHERE e.idEnquete = :idEnquete")})
public class Enquete implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "ID_ENQUETE")
    private Integer idEnquete;
    @Basic(optional = false)
    @NotNull
    @Lob
    @Size(min = 1, max = 65535)
    @Column(name = "PERGUNTA")
    private String pergunta;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "fkEnquete")
    private Collection<OpcoesEnquete> opcoesEnqueteCollection;

    public Enquete() {
    }

    public Enquete(Integer idEnquete) {
        this.idEnquete = idEnquete;
    }

    public Enquete(Integer idEnquete, String pergunta) {
        this.idEnquete = idEnquete;
        this.pergunta = pergunta;
    }

    public Integer getIdEnquete() {
        return idEnquete;
    }

    public void setIdEnquete(Integer idEnquete) {
        this.idEnquete = idEnquete;
    }

    public String getPergunta() {
        return pergunta;
    }

    public void setPergunta(String pergunta) {
        this.pergunta = pergunta;
    }

    public Collection<OpcoesEnquete> getOpcoesEnqueteCollection() {
        return opcoesEnqueteCollection;
    }

    public void setOpcoesEnqueteCollection(Collection<OpcoesEnquete> opcoesEnqueteCollection) {
        this.opcoesEnqueteCollection = opcoesEnqueteCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idEnquete != null ? idEnquete.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Enquete)) {
            return false;
        }
        Enquete other = (Enquete) object;
        if ((this.idEnquete == null && other.idEnquete != null) || (this.idEnquete != null && !this.idEnquete.equals(other.idEnquete))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.mycompany.mavenproject1.Enquete[ idEnquete=" + idEnquete + " ]";
    }
    
}
